<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>综合</title>
    <style type="text/css">
        [v-cloak] { display: none; }
    </style>
</head>
<body>
<div id="example">
    <input v-model="newTodo" v-on:blur="addTodo">
    <ul>
        <li v-for="todo in todos">
            <span>{{ todo.text }}</span>
            <button v-on:click="removeTodo($index)">X</button>
        </li>
    </ul>
</div>
<!--<script src="../js/jquery-2.1.4.min.js"></script>-->
<script src="../js/vue.js"></script>
<script>
    new Vue({
        el: '#example',
        data: {
            newTodo: '',
            todos: [
                { text: 'Add some todos' }
            ]
        },
        methods: {
            addTodo: function () {
                var text = this.newTodo.trim();
                if(text){
                    this.todos.push({text: text});
                    this.newTodo = '';
                }
            },
            removeTodo: function (index) {
                this.todos.splice(index, 1);
            }
        }
    });
</script>
</body>
</html>